package com.platform.modules.sys.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.utils.Query;
import com.platform.modules.sys.dao.ExamineConfigDao;
import com.platform.modules.sys.entity.ExamineConfigEntity;
import com.platform.modules.sys.service.ExamineConfigService;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Service实现类
 *
 * @author 肖亮
 * @date 2019-07-10 19:17:09
 */
@Service("examineConfigService")
public class ExamineConfigServiceImpl extends ServiceImpl<ExamineConfigDao, ExamineConfigEntity> implements ExamineConfigService {

    @Override
    public List<ExamineConfigEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.id");
        params.put("asc", false);
        Page<ExamineConfigEntity> page = new Query<ExamineConfigEntity>(params).getPage();
        return page.setRecords(baseMapper.selectExamineConfigPage(page, params));
    }

    @Override
    public boolean add(ExamineConfigEntity examineConfig) {
        return this.save(examineConfig);
    }

    @Override
    public boolean update(ExamineConfigEntity examineConfig) {
        return this.updateById(examineConfig);
    }

    @Override
    public boolean delete(String id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(String[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }

	@Override
	public List<ExamineConfigEntity> selectSqlByValueAndKey(Map<String, Object> params) {
		 return baseMapper.selectSqlByValueAndKey(params);
	}
	
	@Override
	public boolean updateByKeyStatus(@Param("params") Map<String, Object> params) {
		  return baseMapper.updateByKeyStatus(params);
	  }

	@Override
	public ExamineConfigEntity queryByKey(String Key) {
		// TODO Auto-generated method stub
		Map<String, Object> params=new HashMap<String,Object>();
		params.put("key", Key);
		params.put("status", "1");
		return baseMapper.queryByKey(params);
	}
}
